package com.ssy.lingxi.marketing.model.constant;

import java.util.Arrays;

/**
 * 定时任务类型枚举
 * （对应taskAttributes:taskType属性值）
 * @author ds
 * @date 2021/6/18
 * @version 2.0.0
 */
public enum TaskTypeEnum {

    PF_ACTIVITY_SIGN_UP_START(1, "平台活动报名启动"),
    PF_ACTIVITY_SIGN_UP_END(2, "平台活动报名结束"),
    PF_ACTIVITY_END(3, "平台活动结束"),
    MC_ACTIVITY_END(4, "商家活动结束"),
    PF_COUPON_RELEASE_START(5, "平台优惠券发放开始"),
    PF_COUPON_RELEASE_END(6, "平台优惠券发放结束"),
    MC_COUPON_RELEASE_START(7, "商家优惠券发放开始"),
    MC_COUPON_RELEASE_END(8, "商家优惠券发放结束");

    private final Integer code;
    private final String message;

    TaskTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static class Constants {
        public static final String NAME = "taskType";
        public static final String PLATFORM_USER = "platformUser";
        public static final String ABILITY_USER = "abilityUser";
        public static final String EXECUTE_TIME = "executeTime";
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static String getMessage(Integer code) {
        TaskTypeEnum taskTypeEnum = Arrays.stream(TaskTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return taskTypeEnum == null ? "未知" : taskTypeEnum.getMessage();
    }

}
